package com.cn.servlet.system;


import com.cn.Dao.DbOperateDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "RecoverServlet")
public class RecoverServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String message="";
        request.setCharacterEncoding("GBK");
        response.setCharacterEncoding("GBK");
        try {
            String sql = request.getParameter("sql");
            System.out.println(sql);
            DbOperateDao.doRecover(sql);
            message=sql+"恢复成功";
            System.out.println("恢复成功");
            request.setAttribute("message",message);
            request.getRequestDispatcher("system_maintenance.jsp").forward(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            request.setAttribute("message", message);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
